/*
 * File:         cookieServlet.java
 * Author:       Robert Bittle <guywithnose@gmail.com>
 */
package servlets;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Dude
 *
 */
public class cookieServlet extends HttpServlet
{
    
    /**
     * Get Cookie.
     *
     * @param req the req
     * @param cookieName the cookie name
     * @return the cookie
     */
    protected static String getCookie(HttpServletRequest req, String cookieName)
    {
        Cookie[] cookies = req.getCookies();
        if(cookies != null)
        for(int i = 0; i < cookies.length; i++)
        {
            if(cookies[i].getName().equals(cookieName))
                return cookies[i].getValue();
        }
        return null;
    }
}
